import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * 相对名次
 *
 * @USER: Administrator
 * @DATE: 2024/9/21 上午9:58
 * @VERSION: 1.0.0
 */
public class LC506 {
    public static void main(String[] args) {
        LC506 lc506 = new LC506();
        System.out.println(Arrays.toString(lc506.findRelativeRanks(new int[]{5, 4, 3, 2, 1})));
    }
    public String[] findRelativeRanks(int[] score) {
        Map<String, String> map = new HashMap<>();
        map.put("1", "Gold Medal");
        map.put("2", "Silver Medal");
        map.put("3", "Bronze Medal");
        int[] tmp = new int[score.length];
        System.arraycopy(score, 0, tmp, 0, score.length);
        Arrays.sort(score);
        String[] res = new String[score.length];
        for (int i = 0; i < tmp.length; i++) {
            // 找当前位置是在排序数组的第几位
            for (int j = 0; j < score.length; j++) {
                if (tmp[i] == score[j]) {
                    res[i] = String.valueOf(score.length-j);
                    break;
                }
            }
        }
        for (int i = 0; i < res.length; i++) {
            if (map.get(res[i])!=null){
                res[i] = map.get(res[i]);
            }
        }
        return res;
    }
}
